<?php if(Yii::app()->user->isGuest):?>
<div class="module-top" id="moduleFormLogin1"><i class="icon-lock"></i> Quick Login</div>
	<div class="module" id="moduleFormLogin">
		<div class="alert alert-error" style="display:none">
			<strong>Oh snap!</strong> <label id="message1">Change a few things up and try submitting again.</label>
		</div>
		<div class="alert alert-success" style="display:none">
			<strong>Well done!</strong> <label id="message2">Change a few things up and try submitting again.</label>
		</div>
		<form method="post" action="<?php echo Yii::app()->createUrl('site/login');?>">
			<fieldset>
				<label class="label-main">Username</label>
				<input name="miniusername" class="span12" id="username"  type="text" >
				<label class="label-main">Password</label>
				<input name="miniusername" class="span12" id="pass"  type="password" >
				<p><label class="checkbox"><input type="checkbox">remember me</label></p>
				<button name="send" type="button" value="Submit"  class="btn btn-small btn-info login">Login</button>
			</fieldset>
		</form>
	</div>
	
<script>
$().ready(function(e){
	$(".login").on("click",function(e){
		$.post("<?php echo Yii::app()->createUrl('site/login');?>",{username:$("#username").val(),password:$("#pass").val()},function(res){
			if(res.error){
				$(".alert-error").show();
				$(".alert-success").hide();
				$("#message1").html(res.message);
			}else{
				$(".alert-success").show();
				$(".alert-error").hide();
				$("#message2").html(res.message);
				$("#moduleFormLogin, #moduleFormLogin1").remove();
			}
		});
	});
});
</script>
<?php endif;?>